package com.ist.service;

import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;

import com.ist.dao.VehicleDao;
import com.ist.data.Vehicle;

@Path("/vehicles")
public class VehiclesResource {

	@Context
	UriInfo uriInfo;
	@Context
	Request request;

	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public List<Vehicle> getVehicles(){
		return VehicleDao.getInstance().findAllVehicles();
	}
	
	@PUT
	@Consumes(MediaType.APPLICATION_JSON)
	public Integer putVehicle(Vehicle vehicle) {
		return VehicleDao.getInstance().saveOrUpdateVehicle(vehicle);
	}
	
	@Path("{id}")
	public VehicleResource getVideosLink(
			@PathParam("id") int id) {
		return new VehicleResource(uriInfo, request, id);
	}
}
